//
//  HCCommonTool.h
//  HelperCar
//
//  Created by Jentle on 16/7/26.
//  Copyright © 2016年 Jentle. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface HCCommonTool : NSObject

/**
 *  时间NSString转成指定格式的NSDate
 *
 *  @param dateString  dateString 时间字符串
 *  @param formatStyle formatStyle 指定的格式
 *
 *  @return format之后的NSDate
 */
+ (NSDate *)dateFromString:(NSString *)dateString
           withFormatStyle:(NSString *)formatStyle;

/**
 *  时间NSString转成差量后的NSDate
 *
 *  @param dateString   dateString 时间字符串
 *  @param timeInterval timeInterval 时间差量
 *
 *  @return 改变之后的NSDate
 */
+ (NSDate *)getNotificationMatchDate:(NSString *)dateString
                  addingTimeInterval:(NSTimeInterval)timeInterval;

/**
 *  <#Description#>
 *
 *  @param dateTimeStr <#dateTimeStr description#>
 *
 *  @return <#return value description#>
 */
+(NSDate *)dateFromString:(NSString *)dateTimeStr;


/**
 *  NSDate转成指定格式的时间NSString
 *
 *  @param date        date NSDate
 *  @param formatStyle formatStyle 指定的格式
 *
 *  @return <#return value description#>
 */
+ (NSString *)dateStringFromDate:(NSDate *)date
                 withFormatStyle:(NSString *)formatStyle;


/**
 *  今天偏移offset天数并转化为 yyyy-MM-dd weekday 的格式
 *
 *  @param offset <#offset description#>
 *
 *  @return <#return value description#>
 */
+ (NSString *)dateStringDescriptionByTimeOffset:(NSInteger)offset;


/**
 *  时间字符串截取 MM-dd HH:ss
 *
 *  @param dateString <#dateString description#>
 *
 *  @return <#return value description#>
 */
+ (NSString *)formatterHHhhDate:(NSString *)dateString;


+ (NSString *)formatterDateString:(NSString *)dateString
                    fromFormatter:(NSString *)fromeStyle
                      toFormatter:(NSString *)toStyle;

//*月*日
+ (NSString *)formatterMMDDDate:(NSString *)dateSting;


+ (NSString *)formatterMMDDDateWithWeek:(NSString *)dateSting
                           fomaterStyle:(NSString *)fomaterStyle;

/**
 *  时间字符串截取 mm-ss mm:ss
 *
 *  @param totalTime <#dateString description#>
 *
 *  @return <#return value description#>
 */
+ (NSString *)formattermmssDate:(CGFloat)totalTime;


/**
 *  autolayout 设置父视图大小适应子视图
 *
 *  @param view
 */
+ (void)setFittingFrameWithView:(UIView *)view;


/**
 *  是否字符串全空格
 *
 *  @param string <#string description#>
 *
 *  @return <#return value description#>
 */
+ (BOOL)checkAllIsBlankSpace:(NSString *)string;


/**
 *  纯颜色image
 *
 *  @param color  <#color description#>
 *  @param width  <#width description#>
 *  @param height <#height description#>
 *
 *  @return <#return value description#>
 */
+ (UIImage *)imageFromColor:(UIColor *)color
                      Width:(int)width
                     Height:(int) height;

/**
 *  UIView转图片
 *
 *  @param view <#view description#>
 *
 *  @return <#return value description#>
 */
+ (UIImage *)imageFromView:(UIView *)view;

///**
// *  menu菜单栏数组
// *
// *  @param array <#array description#>
// *  @param type  <#type description#>
// *
// *  @return <#return value description#>
// */
//+ (NSMutableArray *)getMenuList:(NSArray *)array withType:(MenuType)type;


/**
 *  字符串转色值
 *
 *  @param hexColorString <#hexColorString description#>
 *
 *  @return <#return value description#>
 */
+ (UIColor *)colorWithHexColorString:(NSString *)hexColorString;
+ (UIColor *)colorWithHexColorString:(NSString *)hexColorString alpha:(float)alpha;
/**
 *  时长格式化 HH:ss:mm
 *
 *  @param totalTime <#totalTime description#>
 */
+ (NSString *)totalTimeText:(CGFloat)totalTime;

//  得到屏幕快照
+ (UIImage *)getScreenShot;

+ (void)appVersionString;
//  网络状态 0： 无网络  1： wifi  4： 3g/2g
//extern NSInteger NetConnectionStatus();


+ (void)showLoading;

+ (void)hiddenLoading;

+ (NSData *)dataWithImage:(UIImage *)image scaledToSize:(CGSize)newSize;

+ (UIImage *)imageCompressForWidth:(UIImage *)sourceImage targetWidth:(CGFloat)defineWidth;
+ (void)buttonSetTitleAndImageEges:(UIButton *)button;



/**
 *  Controller右上角添加搜索功能
 *
 *  @param vc
 *  @param selector
 */
+ (void)addRightBarButtonItemForSearchInController:(UIViewController *)vc
                                      withSelector:(SEL)selector;

/**
 *  拼接图片
 *
 *  @param path          原地址
 *  @param pathComponent 需要拼接的地址
 *
 *  @return 真正图片地址
 */
+ (NSString *)regularImagePath:(NSString *)path andWithPathComponent:(NSString *)pathComponent;

/**
 *  getUnixStamp 获取当前时间戳
 *
 *  @param NSString
 *  @param NSString
 */
+(NSString*)getUnixStamp;

+(CGSize)sizeForString:(NSString *)string font:(UIFont *)font size:(CGSize)size;
/**
 *  根据url返回图片
 *
 *  @param urlString url
 *
 *  @return 图片
 */
+ (UIImage *)getImageFromURL:(NSString *)urlString;
/**
 *  添加删除线
 *
 *  @param content       字符内容
 *  @param aColor        删除线颜色
 *  @param aBeforeLetter 目的字符串前字符
 *  @param aAfterLetter  目的字符串后字符
 *
 *  @return 带有添加删除线的属性字符
 */
+ (NSMutableAttributedString *)addStrikethroughWithContent:(NSString *)content color:(UIColor *)aColor beforeLetter:(NSString *)aBeforeLetter afterLetter:(NSString *)aAfterLetter;

/**
 *  添加下划线
 *
 *  @param content 目的字符串
 *  @param aColor  删除线颜色
 *
 *  @return 带有添加删除线的属性字符串
 */
+ (NSMutableAttributedString *)addStrikethroughWithContent:(NSString *)content color:(UIColor *)aColor;
/**
 *  添加富文本
 *
 *  @param originalStr 原始字符串
 *  @param aRange      目标字符串的范围
 *  @param aSize       富文本字体大小
 *  @param aColor      富文本颜色
 *
 *  @return 富文本属性
 */
+ (NSMutableAttributedString *)stringwithOriginalString:(NSString *)originalStr aRange:(NSRange)aRange aFontSize:(CGFloat)aSize aTextColor:(UIColor *)aColor;
/**
 *  时间戳转为时间字符串
 *
 *  @param timestampStr 时间戳
 *
 *  @return 时间字符串
 */
+ (NSString *)getDateStringFromTimestamp:(NSString *)timestampStr;

/**
 *  设置状态栏默认
 */
+ (void)setStatusBarDefaultStyle;
/**
 *  设置状态栏白色
 */
+ (void)setStatusBarLightContentStyle;

/**
 *  设置圆角(宽和高相等才设置圆角)
 */
+ (void)clipToRoundWithView:(UIView *)aView viewSize:(CGSize)aSize;

//md5加密
+ (NSString *)md5Hash:(NSString *)str;
// 是否有空格
+ (BOOL)hasBlank:(NSString *)string;
//0.中文验证
+ (BOOL)isChinese:(NSString *)inputStr;
//1.电话号验证
+ (BOOL)isMobileNumber:(NSString *)mobileNum;
//2.NSString 为空(nil)的验证
+ (BOOL)isEmptyOrNull:(NSString *)string;
//是否6-18位数字或者字母组合
+ (BOOL)isPassWord:(NSString *)strPassword;

+ (BOOL)isPhoneNumber:(NSString *)str;

//金额按,分割
+ (NSString *)thousandFormatString:(NSString*)string;
/**
 *  归档
 */
+ (void)archiveObject:(id)object forKey:(NSString *)key;
/**
 *  解档
 */
+ (id)unArchiveObjectForKey:(NSString *)key;
/**
 *  删除归档对象
 */
+ (void)removeObjectForKey:(NSString *)key;
/**
 *  添加scale形变动画
 */
+ (void)addScaleAnimation:(UIView *)view beginTime:(CFTimeInterval)interval;
/**
 *  添加opacity渐变动画
 */
+ (void)addFadeAnimation:(UIView *)view beginTime:(CFTimeInterval)interval;
/**
 *  添加抖动动画
 */
+ (void)addShakeAnimation:(UIView *)view rotation:(CGFloat)rotation duration:(CGFloat)duration;
/**
 *  二次确认弹框
 */
+ (void)addSecConfirmAlertWithController:(UIViewController *)viewController title:(NSString *)title message:(NSString *)message confiemAction:(void(^)(UIAlertAction *action))confiemAction;

+ (instancetype)createViewFromNib;

@end
